package org.example.myleet.p495;

public class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int sumTime = 0;
        for (int i = 1; i < timeSeries.length; ++i) {
            int interval = timeSeries[i] - timeSeries[i - 1];
            if (interval > duration) {
                sumTime += duration;
            } else {
                sumTime += interval;
            }
        }
        sumTime += duration;
        return sumTime;
    }
}
